Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist bash history in devcontainer #4389

Closed

Conversation

tonynajjar
Copy link
Contributor

Persist the bash history of devcontainer in a local volume

Copy link
Member

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave final approval to @ruffsl

@SteveMacenski SteveMacenski requested a review from ruffsl May 31, 2024 21:13
@tonynajjar
Copy link
Contributor Author

tonynajjar commented May 31, 2024

@SteveMacenski what's up with the tests now 😭 Why is this showing up now

@SteveMacenski
Copy link
Member

@SteveMacenski what's up with the tests now 😭 Why is this showing up now

Welcome to my life as a Nav2 maintainer 🙃 😆

@tonynajjar
Copy link
Contributor Author

@SteveMacenski I added one more thing: auto-sourcing of overlay if it exists, otherwise source underlay

@tonynajjar
Copy link
Contributor Author

In my own projects I generate docker images for every PR to be able to easily "checkout" a PR (code + environment). I guess we don't do that here right? It would have helped me test this PR better. Is this an idea you'd be open to? If you're worried about CI time, it can be triggered manually

nav2_bashrc Outdated
@@ -0,0 +1,14 @@
OVERLAY_DIR=/opt/overlay_ws
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in /tools not in the root of the repository please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice, I was looking for a better place

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/tools is our catch-all for random developer tools

source $UNDERLAY
fi

# https://code.visualstudio.com/remote/advancedcontainers/persist-bash-history
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the vscode docs recommends to bake this into the Dockerfile, but I think that's just adds unnecessary opportunities to bust the docker layer cache when it doesn't have to. Please add such user session config to the postCreateCommand where we already manage things like .bashrc.

# Enable autocomplete for user
cp /etc/skel/.bashrc ~/

# https://docs.ros.org/en/rolling/Tutorials/Workspace/Creating-A-Workspace.html#source-the-overlay
OVERLAY=$OVERLAY_DIR/install/setup.bash
UNDERLAY=/opt/ros/${ROS_DISTRO}/setup.bash
if [ -f "$OVERLAY" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we should add this kind of logic to a one off script. Let's add an alias to the .bashrc instead, as we still may need to open a shell without automatically sourcing a workspace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we still may need to open a shell without automatically sourcing a workspace

I'm curious to know which use cases would be affected by the auto-sourcing of the workspace?

Adding an alias to the bashrc doesn't add much more value to manually doing it (once it's done once and in the bash history, it's easy to pull up).

},
{
"source": "nav2-bashhistory",
"target": "/commandhistory",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I overhaul the user account setup for the devcontainer, we can track such dot files easier than using root level paths.

Signed-off-by: Tony Najjar <[email protected]>
@tonynajjar
Copy link
Contributor Author

@ruffsl if you can incorporate the idea of a persistent bash history in your PR I'm happy to close this.

@ruffsl
Copy link
Member

ruffsl commented Jun 8, 2024

if you can incorporate the idea of a persistent bash history in your PR

Feel free to give it a try, I generalized it for any dotfile under the default home directory inside the devcontainer:

I prefer to use fish shell or sometime zsh, so this work for those use cases too.

@tonynajjar
Copy link
Contributor Author

Will give it a try as soon as I can!

@tonynajjar tonynajjar closed this Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants